package chixing.day20.work4;

public class Rider {
    private int riderId;
    private String riderName;
    private boolean isRiderAvailable;
    private int currentOrderCount;
    private Location riderLocation;
    private int riderMaxCapacity;

    public Rider() {
    }

    public Rider(int riderId, String riderName, boolean isRiderAvailable,
                 Location riderLocation, int riderMaxCapacity) {
        this.riderId = riderId;
        this.riderName = riderName;
        this.isRiderAvailable = isRiderAvailable;
        this.currentOrderCount = 0;
        this.riderLocation = riderLocation;
        this.riderMaxCapacity = riderMaxCapacity;
    }

    public int getRiderId() {
        return riderId;
    }

    public void setRiderId(int riderId) {
        this.riderId = riderId;
    }

    public String getRiderName() {
        return riderName;
    }

    public void setRiderName(String riderName) {
        this.riderName = riderName;
    }

    public boolean isRiderAvailable() {
        return isRiderAvailable;
    }

    public void setRiderAvailable(boolean riderAvailable) {
        isRiderAvailable = riderAvailable;
    }

    public int getCurrentOrderCount() {
        return currentOrderCount;
    }

    public void setCurrentOrderCount(int currentOrderCount) {
        this.currentOrderCount = currentOrderCount;
    }

    public Location getRiderLocation() {
        return riderLocation;
    }
    // 在 Rider 类中添加以下方法
    public void setRiderLocation(Location riderLocation) {
        this.riderLocation = riderLocation;
    }

    public int getRiderMaxCapacity() {
        return riderMaxCapacity;
    }

    public void setRiderMaxCapacity(int riderMaxCapacity) {
        this.riderMaxCapacity = riderMaxCapacity;
    }

    // 检查骑手是否可以接单
    public boolean canAcceptOrder() {
        return isRiderAvailable && (currentOrderCount < riderMaxCapacity);
    }

    // 分配订单给骑手
    public void assignOrder() {
        if (canAcceptOrder()) {
            currentOrderCount++;
            if (currentOrderCount >= riderMaxCapacity) {
                isRiderAvailable = false;
            }
        }
    }

    // 完成订单
    public void completeOrder() {
        if (currentOrderCount > 0) {
            currentOrderCount--;
            isRiderAvailable = true;
        }
    }

}

